#!/bin/sh
if [ "${OPENSHIFT_APP_DNS}" == "${OPENSHIFT_GEAR_DNS}" ]; then
  s=$( stat -c %s ${OPENSHIFT_REPO_DIR}php/ip.txt)
  if [ "$s" != "0" ]; then
    echo "==================rsync start==============="
    date
    if [ ! -d "~/app-root/runtime/repo/php/sites/default/files" ]; then
      while read line; do echo "rsync ${line}"; rsync -avz --delete ~/app-root/runtime/repo/php/sites/default/files ${line}:~/app-root/runtime/repo/php/sites/default/; done < ${OPENSHIFT_REPO_DIR}php/ip.txt
    fi
    echo "============================================"
  fi
fi